import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: user
 * Date: 2023-10-31
 * Time: 15:39
 */
public class Test {


    public static void main(String[] args) {
        /*System.out.println(fib2(1));
        System.out.println(fib2(2));
        System.out.println(fib2(5));
        System.out.println(fib2(40));
        System.out.println(count);*/

        //hanoi(64,'A','B','C');
        //中括号当中 不能写数字
        /*int[] array = {1,2,3,4,5};
        int[] array2 = new int[]{1,2,3,4,5};
        int[] array3 = new int[5];

        //int array2[] = {1,2,3,4,5};
        char[] chars = {'a','b','c'};*/


        /*int[] array;
        array = new int[]{1,2,3,4};

        int[] array2;
        array2 = {1,2,3,4};//error*/

        //默认是false
        /*boolean[] array = new boolean[10];
        System.out.println(array[1]);

        String[] array3 = new String[10];
        System.out.println("faa");*/

        int[] array = {1,2,3,4,5};
        /*System.out.println(array[0]);
        array[0] = 199;
        System.out.println(array[0]);
*/

        System.out.println(array.length);

        System.out.println(array);

        /*int[] array2;
        System.out.println(array2);//error 局部变量使用的时候 一定要进行初始化
*/
    }










    /**
     *
     * @param n
     * @param pos1 起始位置
     * @param pos2 中转位置
     * @param pos3 目标位置
     */
    public static void hanoi(int n,char pos1,char pos2,char pos3) {
        if(n == 1) {
            move(pos1,pos3);
            return;
        }
        hanoi(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanoi(n-1,pos2,pos1,pos3);
    }

    public static void move(char pos1,char pos2) {
        System.out.print(pos1+ "-> "+pos2+" ");
    }

    public static int count = 0;

    public static int fib2(int n) {
        if(n == 1 || n == 2) {
            count++;
            return 1;
        }
        int tmp = fib2(n-1) + fib2(n-2);
        return tmp;
    }


    public static int sumEvery(int n) {
        if(n < 10) {
            return n;
        }
        int tmp = n%10 + sumEvery(n/10);
        return tmp;
    }

    public static int sum(int n) {
        if(n == 1) return 1;
        int tmp = n + sum(n-1);
        return tmp;
    }


    public static void print(int n) {
        if(n < 10) {
            System.out.print(n);
            return;
        }
        print(n/10);
        System.out.print(n%10);
    }


    public static int fac(int n) {
        if(n == 1) {
            return 1;
        }
        int tmp = n * fac(n-1);
        return tmp;
    }

    public static void fun(int a) {
        if(a == 1) {
            return;
        }
        fun(a-1);
    }




    //迭代
    public static int fib(int n) {
        if(n == 1 || n == 2) {
            return 1;
        }
        int f1 = 1;
        int f2 = 1;
        int f3 = 0;
        for (int i = 3; i <= n; i++) {
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }

    public static void main7(String[] args) {
        System.out.println(fib(1));
        System.out.println(fib(2));
        System.out.println(fib(3));
        System.out.println(fib(40));
    }

    public static int max(int a,int b) {
        return a > b ? a : b;
    }

    public static int max(int a,int b,int c) {
        int maxNum = max(a,b);
        int ret = max(c,maxNum);
        return ret;
    }



    public static void main4(String[] args) {
        int count = 3;
        Scanner scanner = new Scanner(System.in);
        while (count != 0) {
            System.out.println("请输入你的密码：");
            String passWord = scanner.nextLine();
            //if(passWord == "123456") {
            if(passWord.equals("123456")) {
                System.out.println("登录成功了！");
                return;
            }else {
                count--;
                System.out.println("你还有 "+count+"次机会！");
            }
        }
    }

    public static void main3(String[] args) {
        int n = 123;
        while (n != 0) {
            System.out.println(n%10);//3 2 1
            n /= 10;//12  1  0
        }
    }

    public static void main2(String[] args) {
        double sum = 0;
        int ret = 1;
        for (int i = 1; i <= 100; i++) {
            sum += 1.0/i * ret;
            ret = -ret;
        }
        System.out.println(sum);
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            for(int i = 0;i < n;i++) {
                for(int j = 0;j < n;j++) {
                    if(i == j || i+j == n-1) {
                        System.out.print("*");
                    }else {
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }
        }
    }
}
